package com.cyt.sys.model.po;

import com.cyt.base.util.BaseUtil;
import com.cyt.base.util.DictCode;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;


/**
 * 基础部分-角色
 *
 * @author shengQiang yu
 * @date 2019-04-24 9:09
 */
@Data
@NoArgsConstructor
@Table(name = "base_role")
public class SysRole implements Serializable {

    /**
     * 主键
     */
    @Id
    private String id;

    /**
     * 角色名称
     */
    @Column(name = "role_name")
    private String roleName;

    /**
     * 菜单权限
     */
    @Column(name = "permission")
    private String permission;

    /**
     * 状态标识：1、正常，2、禁用
     */
    @Column(name = "status")
    private String status;

    /**
     * 排序
     */
    @Column(name = "sort")
    private Integer sort;

    /**
     * 删除标识：1、正常，2、已删除
     */
    @Column(name = "remove_tag")
    private String removeTag;

    /**
     * 创建人
     */
    @Column(name = "create_user")
    private String createUser;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    private Date createTime;

    /**
     * 修改时间
     */
    @Column(name = "update_time")
    private Date updateTime;

    /**
     * 修改人
     */
    @Column(name = "update_user")
    private String updateUser;

    /**
     * 菜单id集合
     */
    @Transient
    private String menuIds;

    /**
     * 用户id集合
     */
    @Transient
    private String userIds;

    /**
     * 创建对象
     *
     * @param sysUser 当前用户信息
     * @return
     * @author shengQiang yu
     * @date 2019-04-03 10:53
     */
    public SysRole(SysUser sysUser) {
        this.id = BaseUtil.uId();
        this.removeTag = DictCode.BASE_REMOVE_TAG_NORMAL;
        this.createTime = new Date();
        this.createUser = sysUser.getId();
        this.updateTime = new Date();
        this.updateUser = sysUser.getId();
    }

}
